﻿using DeZhen.DataCollection.Model.DTO.Login;
using Microsoft.AspNetCore.Mvc;

namespace DeZhen.DataCollection.WebApi.Controllers
{
    /// <summary>
    /// 登录
    /// </summary>
    [Route("api/[action]")]
    public class LoginController : ControllerBase
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public LoginController()
        {

        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        [HttpPost(Name = "Login")]
        public IActionResult Login(string username, string password)
        {
            // 这里可以添加实际的登录逻辑，例如验证用户名和密码
            //if (username == "vben" && password == "123456")
            //{
            //    return Ok(new { Token = "fake-jwt-token" });
            //}
            //return Unauthorized();

            return Ok(new { Token = "fake-jwt-token" });
        }

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <returns></returns>
        [HttpGet(Name = "GetUserInfo")]
        public UserInfoDTO GetUserInfo()
        {
            var myRole = new Role() { roleName = "Super Admin", value = "super" };
            List<Role> roles = new List<Role>() { myRole };

            return new UserInfoDTO()
            {
                avatar = "",
                desc = "manager",
                homePath = "/systemSettings/index",
                password = "123456",
                realName = "数据采集",
                roles = roles,
                token = "fakeToken1",
                userId = "1",
                username = "username"
            };
        }

    }
}
